package com.bwie.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.domain.Goods;
import com.bwie.domain.GroupbuyingactivityGoods;
import com.bwie.service.GroupbuyingactivityGoodsService;
import com.bwie.mapper.GroupbuyingactivityGoodsMapper;
import com.bwie.utils.R;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 36167
* @description 针对表【groupbuyingactivity_goods(商品团购信息)】的数据库操作Service实现
* @createDate 2025-03-19 12:17:34
*/
@Service
public class GroupbuyingactivityGoodsServiceImpl extends ServiceImpl<GroupbuyingactivityGoodsMapper, GroupbuyingactivityGoods>
    implements GroupbuyingactivityGoodsService{

    @Autowired
    GroupbuyingactivityGoodsMapper goodsMapper;

    @Override
    public R add(GroupbuyingactivityGoods goods) {
        String[] split = goods.getGoodsIdMode().split(",");
        int i=0;
        for (String s : split) {
            if (!StringUtils.isEmpty(s)){
                goods.setGoodsId(Integer.valueOf(s));
                i+= goodsMapper.add(goods);
            }
        }
        return i>0?R.OK("添加成功"):R.ERROR(500,"添加失败");
    }
}




